package cn.tedu.exec;
/**本类用于oop综合案例*/
public class TestAnimal {
    public static void main(String[] args) {
        Pigeon p = new Pigeon();
        System.out.println(p.LEG_NUMBERS);
        System.out.println(p.eggNumbers);
        p.layEggs();
        p.fly();

        Swallow s = new Swallow();
        System.out.println(s.LEG_NUMBERS);
        System.out.println(s.eggNumber);
        s.fly();
        s.layEggs();
        s.makeNest();

        Ant a = new Ant();
        System.out.println(a.eggNumbers);
        System.out.println(a.LEG_NUMBERS);
        a.fly();
        a.spawn();

        Bee b = new Bee();
        System.out.println(b.eggNumbers);
        System.out.println(b.LEG_NUMBERS);
        b.fly();
        b.spawn();
        b.makeHoney();

    }
}
abstract class Bird{
   final int LEG_NUMBERS = 2;//成员常量
    int eggNumbers;
    public void fly(){
        System.out.println("小鸟飞呀飞");
    }
    public abstract void layEggs();
}
class Pigeon extends Bird{

    @Override
    public void layEggs() {
        System.out.println("会下蛋");
    }
}
class Swallow extends Bird{
    int eggNumber = 6;

    @Override
    public void layEggs() {
        System.out.println("会下蛋,下了"+eggNumber+"个");
    }
    public void makeNest(){
        System.out.println("燕窝很好吃");
    }
}

abstract class Insect{
    final int LEG_NUMBERS = 6;
    int eggNumbers;
    public void fly(){
        System.out.println("飞呀飞");
    }
    public void spawn(){}
}
class Ant extends Insect{
    @Override
    public void spawn(){
        System.out.println("蚂蚁产卵的数量为:300");
    }
}
class Bee extends Insect{
    int eggNumbers = 200;
    public void spawn(){
        System.out.println("蜜蜂的产卵数量为:"+eggNumbers);
    }
    public void makeHoney(){
        System.out.println("蜂蜜很甜，很好吃");
    }
}
